﻿using Clinic.IService;
using Clinic.Model.Model;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Clinic.View.ViewModels
{
    public partial class RoleViewModel : PageViewModel<Role>
    {
        private IRoleService _roleService;

        public RoleViewModel(IRoleService roleService)
        {
            _roleService = roleService;
            PageSize = 1;
            init();
        }
        private async void init()
        {
            await GetPageData();
        }
        public async override Task GetPageData()
        {
            ItemList.Clear();
            var data = await _roleService.GetPaginationDataAsync(PageIndex, PageSize);
            TotalCount = data.TotalCount;
            data.Items.ForEach(role => ItemList.Add(role));
            await base.GetPageData();
        }
    }
}
